package com.own.business.wechat.base.entity.dto;

import com.own.business.wechat.base.entity.bo.WechatUserBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * WechatUserDto
 *
 * @author chenxueli
 * @date 2023-06-29 22:28:56
 */
@Schema(title = "微信用户" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class WechatUserDto extends BaseDto<WechatUserBo> implements Serializable {

    @Schema(title = "所属的appId")
    private String appId;

    @Schema(title = "用户openId")
    private String openId;

    @Schema(title = "用户unionId")
    private String unionId;

    @Schema(title = "用户昵称")
    private String nickname;

    @Schema(title = "性别 0=未知 1=男 2女")
    private Integer sex;

    @Schema(title = "用户个人资料填写的省份")
    private String province;

    @Schema(title = "普通个人资料填写的城市")
    private String city;

    @Schema(title = "国家")
    private String country;

    @Schema(title = "用户头像")
    private String avatar;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public WechatUserBo toBo(WechatUserBo entity) {
        if (entity == null) {
            entity = new WechatUserBo();
        }
        entity.setAppId(this.appId);
        entity.setOpenId(this.openId);
        entity.setUnionId(this.unionId);
        entity.setNickname(this.nickname);
        entity.setSex(this.sex);
        entity.setProvince(this.province);
        entity.setCity(this.city);
        entity.setCountry(this.country);
        entity.setAvatar(this.avatar);
        return super.toBo(entity);
    }

}

